import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TuserVO, TuserForm, TuserQuery } from '@/api/system/tuser/types';

/**
 * 查询用户列表
 * @param query
 * @returns {*}
 */

export const listTuser = (query?: TuserQuery): AxiosPromise<TuserVO[]> => {
  return request({
    url: '/system/tuser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户详细
 * @param id
 */
export const getTuser = (id: string | number): AxiosPromise<TuserVO> => {
  return request({
    url: '/system/tuser/' + id,
    method: 'get'
  });
};

/**
 * 新增用户
 * @param data
 */
export const addTuser = (data: TuserForm) => {
  return request({
    url: '/system/tuser',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户
 * @param data
 */
export const updateTuser = (data: TuserForm) => {
  return request({
    url: '/system/tuser',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户
 * @param id
 */
export const delTuser = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/tuser/' + id,
    method: 'delete'
  });
};
